/**
 * Fix the layout after a resize or zoom in/out.
 */
function fixLayout(){
	fixCanvasHeight();
	if($('#ilenderImg').attr('align')){
		return;
	}
	var mainContainer=$('#mainContainer');
	var width=mainContainer.width();
	var logoImage=$('#ilenderImg img');
	widthForLogo=Math.min(180,width/2-300);
	logoImage.animate({
			width:widthForLogo,
			height:widthForLogo
	});
	var borrowButton=$('#post_request_or_item');
	borrowButton.animate({
			'top':10+logoImage.offset().top+widthForLogo
	});
}

/**
 * Fix the Facebook canvas height to fit the content after a content load.
 */
function fixCanvasHeight(){
	if(window.FB){
		var borrowLendList=$('#generalBorrowLendList');
		FB.Canvas.getPageInfo(function(info){
				FB.Canvas.setSize({'height':Math.max(info.clientHeight,borrowLendList.height()+borrowLendList.position().top)});
		});
	}
}

$(function(){
		$(window).resize(fixLayout);
		fixCanvasHeight();
});
